<?php
namespace app\index\controller;


class Wxpay
{
    //微信支付 - 扫码支付 - 测试
    public function wxpayQrcodeTest()
    {
        $result = wxpayQrcode(build_order_no(),'1234wer3355',10,'商品描述','1');
        $url2 = $result["code_url"];

        //生成二维码
        $savePath = APP_PATH . '/../Public/qrcode/';
        $webPath = '/qrcode/';
        $qrData = $url2;
        $qrLevel = 'H';
        $qrSize = '8';
        $savePrefix = 'tmc';

        if($filename = createQRcode($savePath, $qrData, $qrLevel, $qrSize, $savePrefix)){
            $pic = $webPath . $filename;
        }
        echo  "<img src='".$pic."'>";
    }


    public function wxpayQrcode()
    {
        $result = wxpayQrcode(build_order_no(),'123455','10','商品描述','1');
        $url2 = $result["code_url"];
        //生成二维码
        $savePath = APP_PATH . '/../Public/qrcode/';
        $webPath = '/qrcode/';
        $qrData = $url2;
        $qrLevel = 'H';
        $qrSize = '8';
        $savePrefix = 'tmc';

        if($filename = createQRcode($savePath, $qrData, $qrLevel, $qrSize, $savePrefix)){
            $pic = $webPath . $filename;
        }
        return  "<img src='".$pic."'>";
    }

    //微信支付 - 订单查询 - 测试
    public function payOrderTest()
    {
        $result = wxpayQuery('4200000011201709193042132589','2017091910048541');
        dump($result);
    }

    // 微信支付-退款 - 测试
    public function refundTest()
    {
        $result = wxpayRefund('4200000011201709193042132589','2017091910048541',100,10);
        dump($result);
    }

    // 微信支付 - 退款单查询 - 测试
    public function refundQueryTest()
    {
        // 微信订单号 查询
        //$result = wxpayRefundQuery('4200000011201709193042132589');

        // 商户订单号 查询
        //$result = wxpayRefundQuery('','2017091910048541');

        // 商户订单号 查询(注意：这里查的是 out_refund_no_0 而不是out_refund_no)
        //$result = wxpayRefundQuery('','','140480710220170919233847');

        // 商户订单号 查询(注意：这里查的是 refund_id_0)
        $result = wxpayRefundQuery('','','','50000504262017091901789042036');
        dump($result);

    }

    // 微信支付 - 下载订单 - 测试
    public function wxpayDownloadTest()
    {
        $result = wxpayDownload('20170919','ALL');
        dump($result);
    }

}
